<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var a = Math.floor(Math.random() * 10 + 1);
        //console.log(a);

        while (1) {
            var b = prompt('请输入数字');
            if (b > a) {
                alert('大了');
            } else if (b < a) {
                alert('小了');
            } else {
                alert('猜对了！');
                break;
            }
        }
    </script>
</head>

<body>

</body>

</html>